package weaver.formmode.customjavacode.modeexpand.gyjf;

import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.formmode.customjavacode.modeexpand.gyjf.utils.GyjyUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-idea
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2022-06-13
 * @Description: 固定资产盘点
 * @ModifyLog:
 **/

public class gdzcpdModeExpand extends AbstractModeExpandJavaCodeNew {
    public Map<String, String> doModeExpand(Map<String, Object> param) {
        Map<String, String> result = new HashMap<String, String>();
        try {
            User user = (User) param.get( "user" );
            int billid = -1;//数据id
            int modeid = -1;//模块id
            int userid = -1;//模块id
            RequestInfo requestInfo = (RequestInfo) param.get( "RequestInfo" );
            if (requestInfo != null) {
                billid = Util.getIntValue( requestInfo.getRequestid() );
                modeid = Util.getIntValue( requestInfo.getWorkflowid() );
                userid = Util.getIntValue(user.getUID());
                if (billid > 0 && modeid > 0) {
                    /*
                     *@Description:
                     */
                    RecordSet rs = new RecordSet();
                    rs.writeLog( "WeaSkhtjbxxNewSaveAction-----------------" + billid );
                    //插入主表
                    String sql = "select t.bt,t.pdbh,t.pdjhksrq,t.pdjhjsrq,t.pddw,t.pdry," +
                            "t1.zcbh,t1.zcmc,t1.pdzt,t1.pds,t1.bz" +
                            " from uf_gdzcpdb t left join uf_gdzcpdb_dt1 t1 on t.id=t1.mainid where t.id=?";
                    rs.executeQuery( sql, billid );
                    while (rs.next()) {
                        Map<String, String> map = new HashMap<>();
                        map.put( "bt", Util.null2String( rs.getString( "bt" ) ) );
                        map.put( "pdbh", Util.null2String( rs.getString( "pdbh" ) ) );
                        map.put( "pdjhksrq", Util.null2String( rs.getString( "pdjhksrq" ) ) );
                        map.put( "pdjhjsrq", Util.null2String( rs.getString( "pdjhjsrq" ) ) );
                        map.put( "pddw", Util.null2String( rs.getString( "pddw" ) ) );
                        map.put( "pdry", Util.null2String( rs.getString( "pdry" ) ) );
                        map.put( "zcbh", Util.null2String( rs.getString( "zcbh" ) ) );
                        map.put( "zcmc", Util.null2String( rs.getString( "zcmc" ) ) );
                        map.put( "pdzt", Util.null2String( rs.getString( "pdzt" ) ) );
                        map.put( "pds", Util.null2String( rs.getString( "pds" ) ) );
                        map.put( "bz", Util.null2String( rs.getString( "bz" ) ) );
                        map.put( "pdjh", billid+"");
                        GyjyUtil.insertModelData( 14, userid, map );
                    }
                }
            }
        } catch (Exception e) {
            result.put( "errmsg", "自定义出错信息" );
            result.put( "flag", "false" );
        }
        return result;
    }
}
